/*
 * Btree3D.h
 *
 *  Created on: Apr 6, 2012
 *      Author: hxu
 */

#ifndef BTREE3D_H_
#define BTREE3D_H_

#include<iostream>
#include "BtreeNode.h"
#include "Vnoise.h"
#include "map"

#define WID 0
#define D2D 1

namespace Cxuh {

class Btree3D {
public:
	Btree3D(std::ifstream& setupfs, std::ifstream& topofs);
	virtual ~Btree3D();
	void extractPar(std::ifstream& fs); // extract parameters from file stream
	void parseLine(std::string& strline, std::string& current_node); // parse a line
	void traverse(BtreeNode *nd, std::ostream& out);		// traverse and print
	void build_tree();
	const BtreeNode * getRoot() const {return root;}
	void model_skitter(); // model skitter between each pair of sink

	friend std::ostream& operator << (std::ostream& out, Btree3D& obj);
private:
	BtreeNode *root;
	std::map<int, Vnoise> vnoise_set;
	int num_tsv;
	int num_buf;
	int num_sink;
	int num_mp;
	std::map<std::string, BtreeNode*> node_set;
	std::map<std::string, Wire> wire_set;

	void delete_nodes(BtreeNode *tnode);
};

} /* namespace Cxuh */
#endif /* BTREE3D_H_ */
